import 'package:trollee/app/core/core.dart';

abstract class AuthApis {

  /// 登录成功, 返回登录Token,
  static HttpRequest login({
    required String username,
    required String password,
    required String captcha,
    required String captchaKey,
  }) {
    return HttpUtil().generatePostRequest(
      'auth/trollee/oauth/system/login',
      data: {
        'username': username,
        'password': password,
        'appType': 2, //应用类型[1-管理后台(默认);2-移动管理系统]
        'captcha': captcha, //验证码
        'captchaKey': captchaKey, // 时间戳
      },
    );
  }

  /// 刷新token
  static HttpRequest refreshToken() {
    return HttpUtil().generatePatchRequest('auth/trollee/oauth/system/refresh',
        queryParameters: {'appType': 2, 'refreshToken': ''});
  }

  /// 获取验证码
  /// @param captchaKey 验证码随机数（时间戳）
  static HttpRequest getCode({
    required int captchaKey,
  }) {
    return HttpUtil().generateGetRequest(
        refreshCache: true,
        'auth/trollee/oauth/app/captcha',
        queryParameters: {
          'captchaKey': captchaKey,
        },
    );
  }
}
